﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WMH_Project
{
    public enum MUTATION_TYPE { Normal, Weighted };
    public class MutationParam
    {
        private double propa;
        private MUTATION_TYPE mutationType = MUTATION_TYPE.Normal;
        public MutationParam(double _propa, MUTATION_TYPE _mutationType)
        {
            mutationType = _mutationType;
            propa = _propa;
        }

        public MUTATION_TYPE MutationType
        {
            get { return mutationType; }
        }

        public double Propa
        {
            get { return propa; }
        }
    }
    public enum STOP_REASON { MaxIterations, NoNewBestSpeciment };
    public class StopCondition
    {
        int max;
        int maxWC;
        int iterBest;
        Specimen theBest;
        
        private STOP_REASON stopReason;

        public STOP_REASON StopReason
        {
            get { return stopReason; }
            set { stopReason = value; }
        }
        
        public StopCondition(int _max, int _maxWC)
        {
            max = _max;
            maxWC = _maxWC;
        }
        public string testAndSet(int _iter)
        {
            if (_iter > max)
            {
                stopReason = STOP_REASON.MaxIterations;
                return "przekroczono maksymalną ilość iteracji";
            }
            if (_iter - iterBest > maxWC)
            {
               stopReason = STOP_REASON.NoNewBestSpeciment;
                return "przekroczono maksymalną ilość iteracji bez polepszenia wyniku";
            }


            return null;
        }
        public void setNewBest(Specimen newBest, int _iter)
        {
            iterBest = _iter;
            theBest = newBest;
        }
    }
}
